package mission009;

import java.util.ArrayList;
import java.util.List;

/**
 * @author Admin
 * @create 2019/10/19
 * @since 1.0.0
 */
public class Test2 {
        public static void main(String args[]) {
            Mater tom =new Mater();
            Cat c1=new Cat("小花");
            Cat c2=new Cat("贝贝");
            Dog d1=new Dog("小黑");
            Dog d2=new Dog("旺财");
            Dog d3=new Dog("来福");
            Dog d4=new Dog("阿黄");
            List<Animal> pets = new ArrayList<>();
            pets.add(c1);
            pets.add(c2);
            pets.add(d1);
            pets.add(d2);
            pets.add(d3);
            pets.add(d4);
           List sounds =new ArrayList<>();
                sounds.add("喵");
                sounds.add("汪汪汪");

            List<Food> food=new ArrayList<>();
            food.add(new Food("鱼", 10));
            food.add(new Food("米饭", 3));

            c1.setFoods(food);
            c1.setSounds(sounds);
            c2.setFoods(food);
            c2.setSounds(sounds);
            d1.setFoods(food);
            d1.setSounds(sounds);
            d2.setFoods(food);
            d2.setSounds(sounds);
            d3.setFoods(food);
            d3.setSounds(sounds);
            d4.setFoods(food);
            d4.setSounds(sounds);

            for(Animal o:pets)//Object所有父类的泛型
//        {
//            Animal ia=(Animal)o;//强制性转换，向下转换
            {
                System.out.println("---------------Tom's  pets---------------");
               tom.feed(o);
            }
        }

}
